Add PostgreSQL into Vapor App
Package.swift should like something like this:
// swift-tools-version:4.1
import PackageDescription
let package = Package(
name: "tastee",
dependencies: [
.package(url: "https://github.com/vapor/vapor.git", from: "3.0.0-rc.2"),
.package(url: "https://github.com/vapor/leaf.git", from: "3.0.0-rc"),
.package(url: "https://github.com/vapor/fluent-postgresql.git", from: "1.0.0-rc.2"),
],
targets: [
.target(name: "App", dependencies: ["FluentPostgreSQL", "Vapor"]),
.target(name: "Run", dependencies: ["App"]),
.testTarget(name: "AppTests", dependencies: ["App"])
]
)
After you change anything in Package.swift
, it’s best to
- Close your Vapor Xcode project
- Let the Vapor Toolbox re-create the Xcode project.
vapor xcode -y
Prev: Install PostgreSQL In Docker
Next: Configure a Database in Vapor